define([
  './themes/lang/' + window.YUFP_SYS_CONFIG.language + '/pages/content/systemManager/logManager/logManager.js'
], function (require, exports) {
  // page加载完成后调用ready方法
  exports.ready = function (hashCode, data, cite) {
    yufp.lookup.reg('LOG_TYPE');
    // 日志类型下拉框
    yufp.custom.vue({
      el: '#logManager',
      data: function () {
        var me = this;
        return {
          formdata: {},
          exportCheck: !yufp.session.checkCtrl('export'),
          deleteCheck: !yufp.session.checkCtrl('batchdelete'),
          pickerStartOptions: {
            disabledDate: function (time) {
              if (me.formdata.endTime) {
                return (
                  time.getTime() > new Date(me.formdata.endTime).getTime()
                );
              }
            }
          },
          pickerEndOptions: {
            disabledDate: function (time) {
              if (me.formdata.beginTime) {
                return (
                  time.getTime() < new Date(me.formdata.beginTime).getTime()
                );
              }
            }
          },
          dialogVisible: false,
          checkbox: true,
          height: yufp.custom.viewSize().height - 140,
          dataUrl: backend.msmFrontWebService + '/api/monitor/auditlogdata',
          dataParams: {},
          tableColumns: [{
            label: this.$t('logManager.czzxm'),
            prop: 'userName',
            width: 130
          }, {
            label: this.$t('logManager.czzjg'),
            prop: 'orgName',
            headerAlign: 'center',
            width: 120
          }, {
            label: this.$t('logManager.dl'),
            prop: 'loginIp',
            headerAlign: 'center',
            width: 120
          }, {
            label: this.$t('logManager.czsj'),
            prop: 'operTime',
            width: 150
          }, {
            label: this.$t('logManager.rzlx'),
            headerAlign: 'center',
            prop: 'logTypeId',
            width: 110,
            type: 'select',
            dataCode: 'LOG_TYPE'
          }, {
            label: this.$t('logManager.czdx'),
            prop: 'operObjId',
            headerAlign: 'center',
            width: 130
          }, {
            label: this.$t('logManager.cznr'),
            prop: 'content',
            headerAlign: 'center'
          }]
        };
      },
      methods: {
        queryMainGridFn: function (params) {
          var me = this;
          me.$refs.logtable.remoteData(params);
        },
        queryLogFn: function () {
          var con = this.$refs.queryCon.fm;
          var param = {
            condition: JSON.stringify(con)
          };
          this.queryMainGridFn(param);
        },
        getSelection: function () {
          this.$alert(this.$refs.logtable.selections, this.$t('logManager.ts'));
        },
        getSelectedRow: function (row) {
          // 获取选中行
        },
        deleteLogInfo: function () { // 删除日志信息
          var me = this;

          var selects = this.$refs.logtable.selections;
          if (selects.length == 0) {
            me.$message(me.$t('logManager.qzsxzytsj'), me.$t('logManager.jg'));
            return false;
          }
          me.$confirm(me.$t('logManager.sfqdscsxsj'), me.$t('logManager.ts'), {
            confirmButtonText: me.$t('logManager.qd'),
            cancelButtonText: me.$t('logManager.qx'),
            type: 'warning'
          }).then(function () {
            // var array = new Array(ids);
            yufp.service.request({
              url: backend.msmFrontWebService + '/api/monitor/auditlogdata/batchdelete',
              method: 'post',
              // data: JSON.stringify(array),
              data: JSON.stringify(selects),
              callback: function (code, message, response) {
                if (code == 0 && response.code == 0) {
                  me.$message(me.$t('logManager.scjlcg'), me.$t('logManager.ts'));
                } else {
                  me.$message(me.$t('logManager.scjlsb'), me.$t('logManager.ts'));
                }
                me.queryMainGridFn();
              }
            });
          }).catch(function () { });
        },
        exportLog: function () {
          var me = this;
          var con = {};

          yufp.extend(con, me.$refs.queryCon.fm);

          var selects = this.$refs.logtable.selections;

          var params = [];
          for (var i = 0; i < selects.length; i++) {
            params[i] = selects[i].logId;
          }

          if (selects.length > 0) {
            con['ids'] = params.join(',');
          }
          var url = backend.msmFrontWebService + '/api/monitor/auditlogdata/export?' + 'condition=' + encodeURI(JSON.stringify(con));
          yufp.util.download(url);
          me.dialogVisible = false;
        }
      }
    });
  };

  exports.onmessage = function (type, message) {

  };
  // page销毁时触发destroy方法
  exports.destroy = function (id, cite) {

  };
});
